/**
 * Project: complex.mina
 * 
 * File Created at 2011-3-16
 * $Id: Server.java 129 2011-03-18 03:43:37Z ymkyve501@163.com $
 * 
 * Copyright 1999-2100 Alibaba.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package com.complex.mina;

import java.net.InetSocketAddress;

import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

/**
 * Server起注册中心的作用
 * 
 * @author gaoliang
 * @date 2011-3-16
 */
public class Server {
    public static void main(String[] args) {
        try {
            NioSocketAcceptor acceptor = new NioSocketAcceptor();
            //filter chain
            DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
            chain.addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory()));
            //handler
            acceptor.setHandler(new ServerHandler());
            //bind
            acceptor.bind(new InetSocketAddress(12345));
            System.out.println("server start");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
